﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc.Html;

namespace QuickApp.MVCControl.FlexiGrid
{
    /// <summary>
    /// 表格的按钮信息
    /// </summary>
    public class FlexiGridButton
    {
        internal string ButtonName { get; private set; }
        internal string ButtonTitle { get; private set; }
        internal string ButtonToolTip { get; private set; }
        internal FlexiGridButtonType ButtonType { get; private set; }
        internal string ButtonOnPress { get; private set; }
        internal string ButtonActionUrl { get; private set; }
        internal object ButtonOptions { get; private set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="buttonName">按钮名称</param>
        /// /// <param name="buttonTitle">按钮显示标题</param>
        public FlexiGridButton(string buttonName, string buttonTitle)
        {
            this.ButtonName = buttonName;
            this.ButtonTitle = buttonTitle;
        }

        /// <summary>
        /// 设置按钮的ToolTip（提示信息）
        /// </summary>
        /// <param name="title">提示信息</param>
        /// <returns></returns>
        public FlexiGridButton ToolTip(string title)
        {
            ButtonToolTip = title;
            return this;
        }

        /// <summary>
        /// 设置按钮的类型（新增、修改、删除、导出等）
        /// </summary>
        /// <param name="type">类型（新增、修改、删除、导出等）</param>
        /// <returns></returns>
        public FlexiGridButton Type(FlexiGridButtonType type)
        {
            ButtonType = type;
            return this;
        }

        /// <summary>
        /// 当button被点击时触发的事件 
        /// 接受button的name为第一个参数，Grid为第二个参数的一个function 
        /// </summary>
        /// <returns></returns>
        public FlexiGridButton OnPress(string function)
        {
            ButtonOnPress = function;
            return this;
        }

        /// <summary>
        /// 超链接地址 
        /// </summary>
        /// <returns></returns>
        public FlexiGridButton Action(string actionUrl)
        {
            ButtonActionUrl = actionUrl;
            return this;
        }

        /// <summary>
        /// 按钮的选项参数，可以用于设置弹出层的宽度、高度等属性
        /// </summary>
        /// <returns></returns>
        public FlexiGridButton Options(object opts)
        {
            ButtonOptions = opts;
            return this;
        }

    }
}
